package com.duapk.search.work;

import java.io.IOException;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.function.CustomScoreProvider;

import com.duapk.search.bean.IndexBrief;

public class ApkCustomScoreProvider extends CustomScoreProvider {

	private IndexBrief brief;

	private float starWeight;

	public ApkCustomScoreProvider(IndexReader reader, IndexBrief brief,
			float starWeight) {
		super(reader);
		this.brief = brief;
		this.starWeight = starWeight;
	}

	@Override
	public float customScore(int doc, float subQueryScore, float valSrcScore)
			throws IOException {
		float star = brief.getStar(doc);
		return subQueryScore * (1.0f + star * star * starWeight);
	}
}
